import json
# import os
#
# # 获取目标文件夹中所有图片的文件名
# folder_path = './'  # 替换为你的目标文件夹路径
# image_files = [f for f in os.listdir(folder_path) if f.endswith('.jpeg') or f.endswith('.png')]
with open('../data.json', encoding="utf-8") as f:
    l = f.read()
k = json.loads(l)['data']
for i in range(len(k)):
    a = k[i]
    a["main"] = "火龙果病虫害"
    k[i] = a
print(k)
# 遍历图片文件，并修改名称
# for i, file_name in enumerate(image_files):
#     # 构建新的文件名
#     new_name = f'{k[i]["title"]}.{file_name.split(".")[-1]}'  # 新的文件名，格式为 image_1.jpg, image_2.png，依次递增
#
#     # 构建完整的旧路径和新路径
#     old_path = os.path.join(folder_path, file_name)
#     new_path = os.path.join(folder_path, new_name)
#
#     # 使用 rename() 方法重命名文件
#     os.rename(old_path, new_path)
#
#     print(f'Renamed file "{file_name}" to "{new_name}"')
